home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJPRF106.ARJ / GCRT0.S < prev    next >
Text File  |  1992-03-28  |  2KB  |  94 lines

  1.  
  2. /*
  3. **    Called as start(argc, argv, envp)
  4. */
  5.  
  6.     .text
  7.     .globl    start
  8. start:
  9.     movl    %esp,%ebx
  10.     call    mcount_init /* initialize the profiler */
  11.     movl    8(%ebx),%eax
  12.     pushl    %eax
  13.     movl    %eax,_environ
  14.     pushl    4(%ebx)
  15.     pushl    (%ebx)
  16.     call    ___main
  17.     call    _main
  18.     addl    $12,%esp
  19.     pushl    %eax
  20.     call    _exit
  21.  
  22. exit_again:
  23.     movl    $0x4c00,%eax
  24.     int    $0x21
  25.     jmp    exit_again
  26.  
  27.     ret
  28.  
  29.  
  30.     .globl    __exit
  31. __exit:
  32.     call    mcount_write /* make sure we dump the output */
  33. exit_again2:
  34.     movb    4(%esp),%al
  35.     movb    $0x4c,%ah
  36.     int    $0x21
  37.     jmp    exit_again2
  38.  
  39. /* Here is where we initialize the timer interrupt - specific to go32 */
  40. /* In this case, the timer calls mcount_isr */
  41.     .globl    mcount_isr_init
  42. mcount_isr_init:
  43.     movw    $16,%ax
  44.     movw    %ax,%gs
  45.  
  46.     movl    $960,%eax    /* vector 0x78 * 8 bpv */
  47.     movw    %gs:(%eax),%cx
  48.     movw    %cx,mc_chain
  49.     movw    %gs:6(%eax),%cx
  50.     movw    %cx,mc_chain_hi
  51.     movw    %gs:2(%eax),%cx
  52.     movw    %cx,mc_chain_sel
  53.  
  54.     movl    $mcount_isr,%ecx
  55.     movw    %cx,%gs:(%eax)
  56.     movw    $64,%gs:2(%eax)    /* selector 8 == 32-bit code */
  57.     movw    $0x8f00,%gs:4(%eax)
  58.     rorl    $16,%ecx
  59.     movw    %cx,%gs:6(%eax)
  60.     movw    %ds,%ax
  61.     movw    %ax,%gs
  62.     ret
  63.  
  64. /* Obtain the PC where we interrupted, and bump the histogram.  We should  */
  65. /* do error checking here, but we don't.  This routine is specific to go32 */
  66. /* in some spots */
  67. mcount_isr:
  68.     pushl    %eax
  69.     cmpl    $1,mcount_skip
  70.     je    L0
  71.     movl    4(%esp),%eax /* get the PC */
  72.     subl    $0x1020,%eax /* to fit in low..high */
  73.     andl    $0xfffffffc,%eax
  74.     shrl    $1,%eax /* now points to one 4-byte entry */
  75.     addl    mcount_histogram,%eax
  76.     incw    (%eax)
  77. L0:
  78.     popl    %eax
  79.     ljmp    mc_chain /* chain to the next timer vector */
  80.  
  81.     .data
  82.  
  83.     .globl    _environ
  84. _environ:
  85.     .long    0
  86.  
  87. mc_chain:
  88.     .short    0
  89. mc_chain_hi:
  90.     .short    0
  91. mc_chain_sel:
  92.     .short    0
  93.  
  94.